/* 
 * Copyright [2018] [Alex/libo(liboware@gmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.aop.test.weave;

import com.hyts.aop.annotation.After;
import com.hyts.aop.annotation.Aspect;
import com.hyts.aop.annotation.Before;
import com.hyts.aop.annotation.Round;
import com.hyts.aop.annotation.Weave;
import com.hyts.aop.bean.ProcessArg;

import java.lang.reflect.Array;

/** 
 * @author LiBo/Alex
 * @since TODO引入特定改变发布版本
 * @version V1.0 
 */
@Weave(order=0)
public class WeaveDemo2 {

    @Round
    public void roundMethod(ProcessArg params) {
        Long start = System.currentTimeMillis();
        params.invoke();
        Long end = System.currentTimeMillis();
        //System.out.println(start);
        //System.out.println(end);
        System.out.println(end - start);
    }

    @Before
    public void beforeMethod(ProcessArg params) {
        Array.set(params.getArgument(),0,"ceshi2");
        System.out.println("beforeMethod2");
    }

    @After
    public void afterMethod(ProcessArg params) {
        System.out.println("afterMethod2"+" "+ Array.get(params.getArgument(),0));
    }
}
